package cn.yangliu.jpa.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;


/**
 * 作者 杨柳
 * 创建时间 2017-09-09 19:54
 */
@Configuration
public class JPAConfig {

    @Bean
    public FilterRegistrationBean jpaFilterRegistration(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(new OpenEntityManagerInViewFilter());
        bean.setName("jpaFilter");
        bean.addUrlPatterns("*");
        return bean;
    }
}
